package com.ruoyi.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.order.domain.VerReplies;
import com.ruoyi.service.VerRepliesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/replies")
public class VerRepliesController extends BaseController {
    @Autowired
    private VerRepliesService verRepliesService;

    /**
     * 查询评论回复列表
     */
    @GetMapping("/list/{reviewId}")
    public TableDataInfo list(@PathVariable Long reviewId) {
        startPage();
        List<VerReplies> list = verRepliesService.selectRepliesByReviewId(reviewId);
        return getDataTable(list);
    }

    /**
     * 新增回复
     */
    @PostMapping( "/add")
    public AjaxResult add(@RequestBody VerReplies reply) {
        return toAjax(verRepliesService.insertReply(reply));
    }

    /**
     * 获取回复详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(verRepliesService.selectReplyById(id));
    }
}
